home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
util
/
cli
/
amunix.lha
/
AmunixV103.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-04-18
|
3KB
|
166 lines
Program Unix_Amiga_Strip;
{
Programme Name : Amunix Version : 1.03
Author : Mark Price Date : 13/2/93
Specification:
The programme must return an ASCII text file, after stripping the
original file of extra carriage returns.
}
Uses DOS,CRT;
Const
{Temporary File In Ram Used When Output File Is The Input File}
Temp_file = 'RAM:Aminix.Temp';
Var
Character : Char;
Unix_File : Text;
Unix_Name : String;
Amiga_File : Text;
Amiga_Name : String;
Temp_Name : String;
Res,Count : Integer;
Error : Integer;
DosData : SearchRec;
Procedure Convert_Scripts;
{
Function:
Reads a Character From The Input File, Checks To See If The Value
Of The Character = CHR(13). If It Isn't Then The Character Is Written
To The Output File. If It Is Then The Character Is Skipped.
}
Begin
Reset(Unix_File,Unix_Name); { Open Unix_File For Reading}
Error := IOresult;
If Error <> 0
Then
Begin
WriteLn;
WriteLn('File ',Unix_Name,' Does Not Exist');
WriteLn;
Halt
End;
Rewrite(Amiga_File,Amiga_Name); { Open Amiga File For Writing }
Write('Stripping File ');
TextColor(3);
Write(Amiga_Name);
TextColor(1);
Write(' .... ');
{ While Not At The End OF File Read A Character From Unix_File
If Not a CR then Write The Character To The Amiga_File
}
While NOT EOF(Unix_File) Do
Begin
Read(Unix_File,Character);
IF Character <> CHR(13)
Then
Write(Amiga_File,Character);
End;
{ Close Both The Unix_File and The Amiga_File }
Close(Unix_File);
Close(Amiga_File);
WriteLn('Finished')
End;
Begin
{ Check Number Of Parameters Passed To Program }
Res := ParamCount;
If (Res<2) And (Res>0)
Then
Begin
WriteLn;
WriteLn('Too Few Arguements');
Halt;
WriteLn
End;
If (Res=0) { If No Parameters Passed Display Command Syntax }
Then
Begin
TextColor(3);
WriteLn;
WriteLn('© Mark Price 1993 Version 1.03');
WriteLn('Converts PC/Unix ASCII Files To Amiga ASCII');
WriteLn;
TextColor(2);
HighVideo;
Write('Amunix ');
NormVideo;
TextColor(1);
WriteLn('<UnixFile> <AmigaFile>');
HighVideo;
Write(' -r ');
NormVideo;
WriteLn('<FileName> WildCards Accepted');
WriteLn;
Halt
End;
If (Res>2)
Then
Begin
WriteLn;
WriteLn('Too Many Arguements');
WriteLn;
Halt
End;
Amiga_Name := ParamStr(2); { Amiga_File Name = Second Parameter }
If ParamStr(1)='-r' { If First Parameter='-r' Then Execute This }
Then
Begin
{ Find First File Matching Amiga_Name }
FindFirst(Amiga_Name,AnyFile,DosData);
While (DosError=0) Do
Begin
With DosData Do
Amiga_Name := Name;
{ Create Copy Of Amiga_File }
Exec('Copy',Amiga_Name+' '+Temp_File);
Erase(Amiga_Name);
Unix_Name := Temp_File;
Convert_Scripts;
Erase(Temp_File);
FindNext(DosData)
End;
End
Else
Begin
Unix_Name := ParamStr(1);
If Unix_Name = Amiga_Name
Then
Begin
WriteLn;
WriteLn('Cannot Amunix Onto Same FileName');
WriteLn;
Halt
End;
Convert_Scripts
End;
WriteLn(Chr(7));
WriteLn
End.